<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />    
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>
    <header class="header header-f" style="padding-top:2rem; height:4rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            会员资料
        </div>
        <div class="header-r aui-pull-right" tapmode onclick="userdata()">
            <span>编辑</span>
        </div>
    </header>
    <div style="height:4rem;"></div>

    <div class="aui-content aui-margin-b-15">
        <div id="list">
        <!-- <ul class="aui-list aui-list-in">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        姓名：
                    </div>
                    <div class="aui-list-item-input">
                        会员姓名
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        手机号：
                    </div>
                    <div class="aui-list-item-input">
                        18888888888
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        银行卡：
                    </div>
                    <div class="aui-list-item-input">
                        9558820904001281624
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        出生日期：
                    </div>
                    <div class="aui-list-item-input">
                        1988-01-15
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                        地址：
                    </div>
                    <div class="aui-list-item-input">
                        黑龙江省佳木斯市向阳区...
                    </div>
                </div>
            </li>
        </ul> -->
    </div>
</div>

<div class="aui-content-padded">
    <div class="aui-btn aui-btn-danger aui-btn-block aui-btn-sm" onclick="editpwd();">修改密码</div>
    <div class="aui-btn aui-btn-danger aui-btn-block aui-btn-sm" onclick="logout();">退出登录</div>
</div>

</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/template" id="template">
    <ul class="aui-list aui-list-in">
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    姓名：
                </div>
                <div class="aui-list-item-input">
                    {{=it.nickname}}
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    手机号：
                </div>
                <div class="aui-list-item-input">
                    {{=it.tel}}
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    银行卡：
                </div>
                <div class="aui-list-item-input">
                    9558820904001281624
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    出生日期：
                </div>
                <div class="aui-list-item-input">
                    {{=it.birthday}}
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    地址：
                </div>
                <div class="aui-list-item-input">
                    {{=it.province}} {{=it.city}} {{=it.region}}
                </div>
            </div>
        </li>
    </ul>
</script>
<script type="text/javascript">

    apiready = function(){
        loadData();
        reloadListener();
    }
    
    function loadData(){
        var userid = $api.getStorage('userid');
        var authtoken = $api.getStorage('authtoken');
        api.ajax({
            url: webAddress + '/a/member/Member/info',
            method: 'post',
            data: {
                values: {
                },
            },
            headers: {
                TOKEN: token,
                authuid: userid,
                authtoken: authtoken,
                'Content-Type': 'application/x-www-form-urlencoded',
            },
        },function(ret, err){
            if (ret) {
                // alert( JSON.stringify( ret ) );
                if (ret.result) {
                    templateFun(ret.result);
                }
            } else {
                // alert( JSON.stringify( err ) );
                api.toast({
                    msg: err.message,
                    duration: 2000,
                    location: 'bottom',
                    global: 'true',
                });
                return false;
            }
        });
    }

    // 模板赋值函数
    function templateFun(data){
        if (data) {
          var template = $api.byId('template');
          var dotFn = doT.template(template.innerHTML);
          var html = dotFn(data);
          var list = $api.byId('list');
          $api.html(list, html);
      }else{

          var list = $api.byId('list');
          var html = '<h2 style="padding:1rem; text-align:center; color:#999; font-size:1rem;">暂无内容</h2>';
          list.innerHTML = html;
      }
  }

    // 编辑页
    function userdata(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'userdata',
            url: './user_data.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    }

    // 修改密码
    function editpwd(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'edit_password',
            url: './edit_password.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    }

    // 监听事件 (页面刷新)
    function reloadListener(){
        api.addEventListener({
            name: 'reload',
        }, function(ret, err){
         loadData();
     });
    }

    function goodslist(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'goodslist',
            url: './goods_list.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    };

    function logout(){
        api.confirm({
            title: '提示',
            msg: '是否退出?',
            buttons: ['确定', '取消']
        }, function(ret, err){
            if( ret ){
                if (ret.buttonIndex == 1) {
                    $api.setStorage('userid', null);
                    var setSele = 'randomSwitchBtn(0);';
                    api.execScript({
                        name: 'root',
                        script: setSele,
                    });
                    api.closeWin();
                    return false;
                }
            }else{
                 // alert( JSON.stringify( err ) );
                 return false;
             }
         });


    }

    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>